package com.springredis.service;

import com.springredis.entity.User;
import com.springredis.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 文件描述:
 * 创建用户:emotion
 * 创建时间:2018/6/22
 */
@Service
public class UserServiceImpl implements IUserService {


    @Autowired
    private UserDao userDao;

    @Cacheable(value = "user")
    @Override
    public List<User> getLists() {
        System.out.println("出现打印语句则表示没有走缓存");
        return userDao.getLists();
    }

    @CacheEvict(value = "user", allEntries = true)//清空缓存，
    @Override
    public Integer add(User user) {
        return userDao.add(user);
    }
}